package com.dragon.modules.yuegou.query.product;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dragon.modules.yuegou.entity.product.ParamEntity;
import com.dragon.modules.yuegou.mybatis.Condition;
import com.dragon.modules.yuegou.mybatis.Query;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

import java.time.LocalDateTime;

/**
 * 商品参数信息表 动态查询条件
 * 
 * @author px
 * @date 2019-03-29 16:06:34
 * @version 2.0
 */
@JsonInclude(Include.NON_NULL)
public class ParamQuery extends ParamEntity implements Query<ParamEntity> {

    /** 查询条件 */
	@JsonUnwrapped(prefix = "id")
	private Condition<String> idCondition;

    /** 查询条件 */
	@JsonUnwrapped(prefix = "spuId")
	private Condition<String> spuIdCondition;

    /** 属性ID查询条件 */
	@JsonUnwrapped(prefix = "attributeId")
	private Condition<String> attributeIdCondition;

    /** 属性名称查询条件 */
	@JsonUnwrapped(prefix = "attributeName")
	private Condition<String> attributeNameCondition;

    /** 参数值查询条件 */
	@JsonUnwrapped(prefix = "paramValue")
	private Condition<String> paramValueCondition;

    /** 属性解释查询条件 */
	@JsonUnwrapped(prefix = "explanation")
	private Condition<String> explanationCondition;

    /** 创建时间查询条件 */
	@JsonUnwrapped(prefix = "createdTime")
	private Condition<LocalDateTime> createdTimeCondition;

	/**
	 * 构造一个查询条件对象
	 */
	public ParamQuery() {
		super();
	}

	/**
	 * 依据实体对象构造一个查询条件对象
	 * 
	 * @param entity 实体对象
	 */
	public ParamQuery(ParamEntity entity) {
		super(entity);
	}

	/**
	 * 依据其它查询条件对象的信息构造一个查询条件对象
	 * 
	 * @param other 查询条件对象
	 */
	public ParamQuery(ParamQuery other) {
		super(other);
		if(other.idCondition != null) {
			this.idCondition = other.idCondition.copy();
		}
		if(other.spuIdCondition != null) {
			this.spuIdCondition = other.spuIdCondition.copy();
		}
		if(other.attributeIdCondition != null) {
			this.attributeIdCondition = other.attributeIdCondition.copy();
		}
		if(other.attributeNameCondition != null) {
			this.attributeNameCondition = other.attributeNameCondition.copy();
		}
		if(other.paramValueCondition != null) {
			this.paramValueCondition = other.paramValueCondition.copy();
		}
		if(other.explanationCondition != null) {
			this.explanationCondition = other.explanationCondition.copy();
		}
		if(other.createdTimeCondition != null) {
			this.createdTimeCondition = other.createdTimeCondition.copy();
		}
	}

	@Override
	public QueryWrapper<ParamEntity> toQueryWrapper() {
		QueryWrapper<ParamEntity> wrapper = new QueryWrapper<>(this);
		if (idCondition != null) {
			idCondition.toWrapper(wrapper, COL_ID);
		}
		if (spuIdCondition != null) {
			spuIdCondition.toWrapper(wrapper, COL_SPU_ID);
		}
		if (attributeIdCondition != null) {
			attributeIdCondition.toWrapper(wrapper, COL_ATTRIBUTE_ID);
		}
		if (attributeNameCondition != null) {
			attributeNameCondition.toWrapper(wrapper, COL_ATTRIBUTE_NAME);
		}
		if (paramValueCondition != null) {
			paramValueCondition.toWrapper(wrapper, COL_PARAM_VALUE);
		}
		if (explanationCondition != null) {
			explanationCondition.toWrapper(wrapper, COL_EXPLANATION);
		}
		if (createdTimeCondition != null) {
			createdTimeCondition.toWrapper(wrapper, COL_CREATED_TIME);
		}
		return wrapper;
	}

	/**
	 * 构造并返回查询条件
	 * 
	 * @return idCondition 查询条件
	 */
	public Condition<String> id() {
		this.idCondition = new Condition<>();
		return this.idCondition;
	}
	
	/**
	 * 获取查询条件
	 * 
	 * @return idCondition 查询条件
	 */
	public Condition<String> getIdCondition() {
		return idCondition;
	}

	/**
	 * 设置查询条件
	 * 
	 * @param idCondition 查询条件
	 */
	public void setIdCondition(Condition<String> idCondition) {
		this.idCondition = idCondition;
	}

	/**
	 * 构造并返回查询条件
	 * 
	 * @return spuIdCondition 查询条件
	 */
	public Condition<String> spuId() {
		this.spuIdCondition = new Condition<>();
		return this.spuIdCondition;
	}
	
	/**
	 * 获取查询条件
	 * 
	 * @return spuIdCondition 查询条件
	 */
	public Condition<String> getSpuIdCondition() {
		return spuIdCondition;
	}

	/**
	 * 设置查询条件
	 * 
	 * @param spuIdCondition 查询条件
	 */
	public void setSpuIdCondition(Condition<String> spuIdCondition) {
		this.spuIdCondition = spuIdCondition;
	}

	/**
	 * 构造并返回属性ID查询条件
	 * 
	 * @return attributeIdCondition 属性ID查询条件
	 */
	public Condition<String> attributeId() {
		this.attributeIdCondition = new Condition<>();
		return this.attributeIdCondition;
	}
	
	/**
	 * 获取属性ID查询条件
	 * 
	 * @return attributeIdCondition 属性ID查询条件
	 */
	public Condition<String> getAttributeIdCondition() {
		return attributeIdCondition;
	}

	/**
	 * 设置属性ID查询条件
	 * 
	 * @param attributeIdCondition 属性ID查询条件
	 */
	public void setAttributeIdCondition(Condition<String> attributeIdCondition) {
		this.attributeIdCondition = attributeIdCondition;
	}

	/**
	 * 构造并返回属性名称查询条件
	 * 
	 * @return attributeNameCondition 属性名称查询条件
	 */
	public Condition<String> attributeName() {
		this.attributeNameCondition = new Condition<>();
		return this.attributeNameCondition;
	}
	
	/**
	 * 获取属性名称查询条件
	 * 
	 * @return attributeNameCondition 属性名称查询条件
	 */
	public Condition<String> getAttributeNameCondition() {
		return attributeNameCondition;
	}

	/**
	 * 设置属性名称查询条件
	 * 
	 * @param attributeNameCondition 属性名称查询条件
	 */
	public void setAttributeNameCondition(Condition<String> attributeNameCondition) {
		this.attributeNameCondition = attributeNameCondition;
	}

	/**
	 * 构造并返回参数值查询条件
	 * 
	 * @return paramValueCondition 参数值查询条件
	 */
	public Condition<String> paramValue() {
		this.paramValueCondition = new Condition<>();
		return this.paramValueCondition;
	}
	
	/**
	 * 获取参数值查询条件
	 * 
	 * @return paramValueCondition 参数值查询条件
	 */
	public Condition<String> getParamValueCondition() {
		return paramValueCondition;
	}

	/**
	 * 设置参数值查询条件
	 * 
	 * @param paramValueCondition 参数值查询条件
	 */
	public void setParamValueCondition(Condition<String> paramValueCondition) {
		this.paramValueCondition = paramValueCondition;
	}

	/**
	 * 构造并返回属性解释查询条件
	 * 
	 * @return explanationCondition 属性解释查询条件
	 */
	public Condition<String> explanation() {
		this.explanationCondition = new Condition<>();
		return this.explanationCondition;
	}
	
	/**
	 * 获取属性解释查询条件
	 * 
	 * @return explanationCondition 属性解释查询条件
	 */
	public Condition<String> getExplanationCondition() {
		return explanationCondition;
	}

	/**
	 * 设置属性解释查询条件
	 * 
	 * @param explanationCondition 属性解释查询条件
	 */
	public void setExplanationCondition(Condition<String> explanationCondition) {
		this.explanationCondition = explanationCondition;
	}

	/**
	 * 构造并返回创建时间查询条件
	 * 
	 * @return createdTimeCondition 创建时间查询条件
	 */
	public Condition<LocalDateTime> createdTime() {
		this.createdTimeCondition = new Condition<>();
		return this.createdTimeCondition;
	}
	
	/**
	 * 获取创建时间查询条件
	 * 
	 * @return createdTimeCondition 创建时间查询条件
	 */
	public Condition<LocalDateTime> getCreatedTimeCondition() {
		return createdTimeCondition;
	}

	/**
	 * 设置创建时间查询条件
	 * 
	 * @param createdTimeCondition 创建时间查询条件
	 */
	public void setCreatedTimeCondition(Condition<LocalDateTime> createdTimeCondition) {
		this.createdTimeCondition = createdTimeCondition;
	}

}
